From e407460bcb3af0e44169f614a30d781a2509097f Mon Sep 17 00:00:00 2001 From: Ilmari Karonen Date: Thu, 4 Mar 2010 00:27:44 +0000 Subject: [PATCH] followup to r63221: skip update and emit warning if revision text cannot be found --- maintenance/populateRevisionLength.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/maintenance/populateRevisionLength.php b/maintenance/populateRevisionLength.php index 2ee67794b6..13868f051a 100644 --- a/maintenance/populateRevisionLength.php +++ b/maintenance/populateRevisionLength.php @@ -49,6 +49,7 @@ class PopulateRevisionLength extends Maintenance { $blockStart = intval( $start ); $blockEnd = intval( $start ) + $this->mBatchSize - 1; $count = 0; + $missing = 0; while( $blockStart <= $end ) { $this->output( "...doing rev_id from $blockStart to $blockEnd\n" ); $res = $db->select( 'revision', @@ -61,12 +62,19 @@ class PopulateRevisionLength extends Maintenance { foreach( $res as $row ) { $rev = new Revision( $row ); $text = $rev->getRawText(); - # Update the row... - $db->update( 'revision', - array( 'rev_len' => strlen( $text ) ), - array( 'rev_id' => $row->rev_id ), - __METHOD__ ); - $count++; + if( !is_string( $text ) ) { + # This should not happen, but sometimes does (bug 20757) + $this->output("Text of revision {$row->rev_id} unavailable!\n"); + $missing++; + } + else { + # Update the row... + $db->update( 'revision', + array( 'rev_len' => strlen( $text ) ), + array( 'rev_id' => $row->rev_id ), + __METHOD__ ); + $count++; + } } $blockStart += $this->mBatchSize; $blockEnd += $this->mBatchSize; @@ -77,7 +85,7 @@ class PopulateRevisionLength extends Maintenance { __METHOD__, 'IGNORE' ); if( $logged ) { - $this->output( "rev_len population complete ... {$count} rows changed\n" ); + $this->output( "rev_len population complete ... {$count} rows changed ({$missing} missing)\n" ); return true; } else { $this->output( "Could not insert rev_len population row.\n" ); -- 2.20.1